package com.example.activity02;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.app.Activity;
import android.content.Intent;

public class MainActivity extends Activity {
	
	private EditText myEditText1 = null;
	private EditText myEditText2 = null;
	private TextView myTextView = null;
	private Button myButton = null;
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myEditText1 = (EditText)findViewById(R.id.myEditText1);
        myEditText2 = (EditText)findViewById(R.id.myEditText2);
        myTextView = (TextView)findViewById(R.id.myTextView);
        myButton = (Button)findViewById(R.id.myButton);
        myTextView.setText(R.string.myTextView);
        myButton.setText(R.string.myButton);
        myButton.setOnClickListener(new View.OnClickListener(){
			@Override
			public void onClick(View v) {
				String OperateOne = myEditText1.getText().toString();
			    String OperateTwo = myEditText2.getText().toString();
				Intent intent = new Intent();
				intent.putExtra("one", OperateOne);
				intent.putExtra("two", OperateTwo);
				intent.setClass(MainActivity.this, OtherActivity.class);
				MainActivity.this.startActivity(intent);
			}
        	
        }
        );
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add(0,1,1,R.string.exit);
		menu.add(0,2,2,R.string.about);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if(item.getItemId() == 1)
		{
			finish();
		}
		return super.onOptionsItemSelected(item);
	}

	
    
}
